<?php
namespace app\validate;

use think\Validate;
use think\Log;

class Users extends Validate
{
  protected $rule = [
    'name' => 'require|max:25',
    'age' => 'number|between:1,125',
    'adress' => 'require',
    'email' => 'email'
  ];

  protected $msg = [
    'name.require' => '名字不能为空',
    'name.max' => '名字不能超过 25 个字符',
    'age.number' => '年龄要是数字',
    'age.between' => '年龄只能在1-120之间',
    'adress.require' => '地址不能为空',
    'email' => '邮箱格式错误',
  ];


  protected $field = [
    'name' => '名称',
    'age' => '年龄',
    'adress' => '地址',
    'email' => '邮箱',
  ];

  protected $scene = [
    'edit' => ['name','age'],
    'qwe' => ['name','age' =>'require']
  ];

  public function getError()
  {
    if (!empty($this->error)) {
      Log::init([
        'type' => 'SeaLog',
        'path' => LOG_PATH,
        'module' => 'validate'
      ]);
      Log::record($this->error, 'info');
    }
    return $this->error;
  }
  
}
